package com.blackhorse.order.controller;

import com.blackhorse.order.entity.Product;
import com.blackhorse.order.feign.ProductFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.Resources;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired //使用自定义的Feign客户端接口进行远程调用
    private ProductFeignClient productFeignClient;

    @GetMapping("/buy/{id}")
    public Product buyProductById(@PathVariable Long id) {
        //优化方法3：使用自定义FeignCilent接口
        Product product = productFeignClient.getProductByFeign(id);
        return product;
    }

}
